package com.ruoyi.web.controller.ring;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ring.domain.RingGroupMessage;
import com.ruoyi.ring.service.IRingGroupMessageService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 群组信息Controller
 * 
 * @author liuwp
 * @date 2025-10-20
 */
@RestController
@RequestMapping("/ring/ring_group_message")
public class RingGroupMessageController extends BaseController
{
    @Resource
    private IRingGroupMessageService ringGroupMessageService;

    /**
     * 查询群组信息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_group_message:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingGroupMessage ringGroupMessage)
    {
        startPage();
        List<RingGroupMessage> list = ringGroupMessageService.selectRingGroupMessageList(ringGroupMessage);
        return getDataTable(list);
    }

    /**
     * 导出群组信息列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_group_message:export')")
    @Log(title = "群组信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingGroupMessage ringGroupMessage)
    {
        List<RingGroupMessage> list = ringGroupMessageService.selectRingGroupMessageList(ringGroupMessage);
        ExcelUtil<RingGroupMessage> util = new ExcelUtil<RingGroupMessage>(RingGroupMessage.class);
        util.exportExcel(response, list, "群组信息数据");
    }

    /**
     * 获取群组信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_group_message:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringGroupMessageService.selectRingGroupMessageById(id));
    }

    /**
     * 新增群组信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_group_message:add')")
    @Log(title = "群组信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingGroupMessage ringGroupMessage)
    {
        return toAjax(ringGroupMessageService.insertRingGroupMessage(ringGroupMessage));
    }

    /**
     * 修改群组信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_group_message:edit')")
    @Log(title = "群组信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingGroupMessage ringGroupMessage)
    {
        return toAjax(ringGroupMessageService.updateRingGroupMessage(ringGroupMessage));
    }

    /**
     * 删除群组信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_group_message:remove')")
    @Log(title = "群组信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringGroupMessageService.deleteRingGroupMessageByIds(ids));
    }
}
